The ==
and !=
operators do type coercion before comparing values. This is bad because it can mask type errors. For
example, it evaluates ' \t\r\n' == 0
as true
.
It is best to always use the side-effect-less ===
and !==
operators instead.
Noncompliant code example
if (var == 'howdy') {...} // Noncompliant
Compliant solution
if (var === 'howdy') {...}